import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;


public class maze {

	private int maze_size;
	private int col;
	private int row;
	private int size;
	private int[][] playField;
	private int eye;

	private Graphics img;
	private npc npc_;
	private ArrayList<objects> fieldArray = new ArrayList<objects>();
	private ArrayList<npc> npcArray = new ArrayList<npc>();
	
	/**
	 * 
	 * constructor
	 * 
	 * @param maze_size_
	 * @param col_
	 * @param row_
	 * @param size_
	 * @param playField_
	 * @param img_
	 * @param eye_
	 */
	public maze(int maze_size_, int col_, int row_, int size_, int[][] playField_, Graphics img_, int eye_)
	{
		maze_size = maze_size_;
		col = col_;
		row = row_;
		size = size_;
		playField = playField_;
		img = img_;
	}
	
	/**
	 * 
	 * Preprocess - fills the fieldArray with objects
	 * 
	 * @return
	 */
	public ArrayList<objects> preprocessMaze()
	{
		objects objects_;
		
		for (row = 0; row < maze_size; row++)
		{
			for (col = 0; col < maze_size; col++)
			{	
				//builds the (simple)walls
				if (playField[row][col] == 1)
				{
					objects_ = new objects(img, col, row, size, 1);
					fieldArray.add(objects_);
				}
				
				//create exit
				if (playField[row][col] == 2)
				{
					objects_ = new objects(img, col, row, size, 2);
					fieldArray.add(objects_);
				}
				
				//color the floors
				if (playField[row][col] == 3)
				{
					objects_ = new objects(img, col, row, size, 3);
					fieldArray.add(objects_);
				}
				
				//create a river
				if(playField[row][col] == 5)
				{
					objects_ = new objects(img, col, row, size, 5);
					fieldArray.add(objects_);
				}
				
				//create coins
				if(playField[row][col] == 7)
				{
					objects_ = new objects(img, col, row, size,7);
					fieldArray.add(objects_);
				}
				
				//create orb
				if(playField[row][col] == 8)
				{
					objects_ = new objects(img, col, row, size, 8);
					fieldArray.add(objects_);
				}
				
				//create woodwalls
				if(playField[row][col] == 9)
				{
					objects_ = new objects(img, col, row, size, 9);
					fieldArray.add(objects_);
				}
			}
		}
		
		return fieldArray;
	}
	
	/**
	 * 
	 * Preprocess - fills the npcArray with enemies
	 * 
	 * @return
	 */
	public ArrayList<npc> preprocessNPC()
	{
		for (row = 0; row < maze_size; row++)
		{
			for (col = 0; col < maze_size; col++)
			{	
				//create static-NPC
				if (playField[row][col] == 4)
				{
					npc_ = new npc(img, col, row, size, (int) eye);
					npcArray.add(npc_);
				}
			}
		}
		
		return npcArray;
	}
}
